home *** CD-ROM | disk | FTP | other *** search
- /*
- * This is perhaps one of the most important objects. It's what deals with reading and
- * writing the bitmaps to and from disk. When used init and free should always be called.
- * The concept of sender is used in a couple of places in this object and should respond to
- * the following request: It should respond to getImageCon and return the id of a ImageControl
- * object. Note that the NXBitmapImageRep links this from disk at run time. You may also
- * do this, should you wish, or you may define your own set of internal routines. Whatever
- * you do, the ImageControl object should respond to everything defined in image.h, and
- * these should have predictable results.
- */
-
- #import <objc/Object.h>
-
- #define CONVERT_ERR_NONE 0
- #define CONVERT_ERR_WARNING 1
- #define CONVERT_ERR_FATAL 2
-
- #define ERROR_NO_ERROR 0
- #define ERROR_UNABLE_TO_OPEN 1
- #define ERROR_PERMISSION_DENIED 2
- #define ERROR_BAD_FORMAT 3
- #define ERROR_TRUNCATED_FILE 4
-
- @interface Converter : Object
- {
- int errState;
- }
-
- /*
- * Initializes the object. This need not necessarily be used, but you can use it if you'd like.
- * Assumes: Nothing
- * Returns: self
- * Results: A new object is up and running.
- */
- - init;
-
- /*
- * Frees anything used by the object.
- * Assumes: Object is instantiated.
- * Results: It is no longer valid to message the object.
- */
- - free;
-
- /*
- * Reads the bitmap from stream.
- * Assumes: The object has been instantiates, stream is an valid stream opened for at least
- * reading. Sender is the id of whatever object is calling the converter.
- * Returns: id of an NXBitmapImageRep or nil if the image was unable to be read.
- */
- - readFromStream: (NXStream *)stream from: sender;
-
- /*
- * Write the bitmaps id to stream.
- * Assumes: Object has been instantiated. At times, it's best to have used a call to the
- * save panel first, since this can set internal variables, but it's not necessary.
- * stream should be a valid NXStream opened for at least writing. Sender should
- * be the id of the caller. id is a NXBitmapImageRep, or something that responds
- * to all the message of the NXBitmapImageRep.
- * Returns: YES if the image was sucessfully writing, otherwise it returns NO.
- */
- - (BOOL)write: (id)image toStream: (NXStream *)stream from: sender;
-
- /*
- * Similar to readFromStream but will read multiple images from a stream when present.
- * Assumes: Object instantiated. stream valid for reading. sender is id of caller.
- * Returns: id of an NXImage or nil if unable to read the image. It should return a single
- * image in the least, even for formats that don't support multiple images.
- */
- - readAllFromStream: (NXStream *)stream from: sender;
-
- /*
- * Reverses the process of read all.
- * Assumes: Object instantiates. id is to an NXImage or something that responds to all of
- * NXImage's methods. stream is valid for writing. This should always attempt
- * to write at least one image to disk (the first usually) even for formats that
- * don't support multiple images.
- * Returns: YES if the image is sucessfully written to disk.
- */
- - (BOOL)writeAll: (id)image toStream: (NXStream *)stream;
-
- /*
- * Creates and lays out a custom view that the converter can use to set customization
- * parameters.
- * Assumes: Object instantiated and the window server is running. width should be the
- * maximum width the custom view can be.
- * Returns: id of a parent view or nil if this object doesn't use one.
- */
- - customSaveView: (int)width;
-
- /*
- * This is very similar to customSaveView, however, it is used to set parameters for
- * the run time loading of images. This object does not support input custom views.
- * Assumes: Object instantiated and the window server is running. width should be the
- * maximum width the custom view can be.
- * Returns: id of a parent view or nil if this object doesn't use one.
- */
- - customOpenView: (int)width;
-
- /*
- * Returns the name of the current format, ie, the gif converter returns the string "Graphics
- * Interchange Format (GIF)".
- * Assumes: Object has been instantiated.
- * Returns: A pointer to a string. The caller should always use something like strcpy to
- * get a copy of the string, since it's life is only guaranteed for the life of the
- * object.
- */
- - (char *)getFormatName;
-
- /*
- * This is a simple interface to setting custom values of various parameters. There are
- * no standards for what a converter must take of these values, so while the converter
- * will tell you whether it took the value you or not, you, as the programmer, should
- * not get upset when a parameter is not taken. Likewise, should the converter receive
- * a request to set a parameter it does not understand, it should always refuse it with
- * grace (ie, make it idiot proof.) What parameters an indivudual converter will take
- * should be documented somewhere with the converters distribution.
- * Assumes: The converter is instantiated, parameter is a NULL terminated character
- * string, and ptr is a pointer to the data type. This is determined by patameter.
- * Returns: YES if the value was set, NO if the setting failed for any reason.
- */
- - (BOOL)setCustomParameter: (const char *)parameter withValue: (void *)ptr;
-
- /*
- * Gets a custom parameter value. See above about support for this call, as it's similar
- * to setCustomParameter. Mainly, the converter should not crash when a request for
- * a non-existant parameter is made.
- * Assumes: The converter is instantiated and parameter is a NULL terminater char-
- * acter string.
- * Returns: A pointer to the parameter (type depends on return value) or nil if the
- * parameter is not understood.
- */
- - (void *)getCustomParameter: (const char *)parameter;
-
- /*
- * Returns a string with copyright information, name of the author, where the author
- * can be reached, etc. This should only be a couple of lines, so keep it short and
- * sweet. An example might be:
- * "My Image Format Converter\nby Joe Programmer\nCopyright R'N'R Software\n ...
- * ... email bugs to jprogramm@system.there.edu"
- * Assumes: Converter linked and instantiated.
- * Returns: A pointer to a null terminated string. This string must be non volatile for
- * the life of the converter. Ie, as long as the programmer keeps a converter
- * linked, the pointer should be valid.
- */
- - (char *)copyrightNotice;
-
- /*
- * Returns the current error state of the converter.
- * Assumes: Converter has been instantiated.
- * Returns: 0 = CONVERT_ERR_NONE Signals no error
- * 1 = CONVERT_ERR_WARNING Signals action taken, but not one expected.
- * 2 = CONVERT_ERR_FATAL Signals no action taken.
- */
- - (int)errorState;
-
- /*
- * Returns an int describing the current error message.
- * Assumes: Converter instantiated.
- * Returns: An int describing the error type. See defines for integers returned.
- */
- - (int)errorMessage;
-
- /*
- * Returns a string in the form <major version>.<minor version>. This is used by
- * the calling program to see what level or protocol the object will respond to.
- * Assumes: Converter instantiated.
- * Returns: A null terminated string in the form <major version>.<minor version>.
- * For example, 1.0.
- */
- - (char *)protocolVersion;
-
- @end
-